<template>
    <div class="video_details">
      <div class="top_back">
        <top-go-back></top-go-back>
      </div>
      <div>
        <video-details-content v-if="videoData" :videoData="videoData"></video-details-content>
      </div>
    </div>
</template>

<script>
  import TopGoBack from '../../components/common/TopGoBack';
  import VideoDetailsContent from '../../components/videoHaiNan/VideoDetailsContent'
  import {getVideoContent} from '../../axios/api';

  export default {
    name: 'VideoDetails',
    data(){
      return{
        videoData:{},
      }
    },
    created(){
      this.getVideoDetails();
    },

    methods:{
      //获取视频内容
      getVideoDetails(){
        let that = this;
        that.videoData = {};
        getVideoContent(this.$route.params.id).then(res=>{
          if (res.status === 200) {
            that.videoData = res.data;
            this.$store.commit('setCircleOfFriendsTitle',res.data.video.title);
            this.$store.commit('setCircleOfFriendsDesc',res.data.video.description);
          }
        }).catch(err=>{
          console.log(err);
        })
      },
    },
    watch: {
      '$route'(to, from) {
        if (to.name === 'VideoDetails') {
          this.getVideoDetails();
        }
      }
    },
    components: {VideoDetailsContent, TopGoBack}
  }
</script>

<style scoped>
.video_details .top_back{
  position: absolute;
  width: 100%;
  left: 0;
  top: 10px;
  z-index: 99;
}
</style>
